#!/usr/bin/env python
# encoding: utf-8
"""
views.py

Created by AlanYang on 2011-06-23.
Copyright (c) 2011 __MyCompanyName__. All rights reserved.
"""
from flask import Module,flash,render_template

import tagmodel

tag = Module(__name__,name='tag')

@tag.route('/')
@tag.route('/<int:page>')
def index(page=1):
    skip = (page-1)*10
    tags = tagmodel.gethottags(skip,10)
    flash('browse tag list')
    flash('has tags %s'%len(tagmodel.TagModel()))
    return render_template('tag/index.html',tags=tags)

@tag.route('/list/<tag>/<int:page>')
def questions(tag,page):
    skip = (page-1)*10
    flash('tag %s questions'%tag)
    questions = tagmodel.getquestions(tag,skip,10) 
    return render_template('question/index.html',qs=questions)